package com.sds.sweng.swat.miplatform.service.figures.components;

import org.dom4j.Node;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.PointList;

import com.sds.sweng.swat.miplatform.service.validation.ValidationInfo;
import com.sds.sweng.swat.miplatform.service.validation.ValidationProperties;
import com.sds.sweng.swat.miplatform.service.validation.ValidationProperty;
import com.sds.sweng.swat.miplatform.service.validation.ValidationType;

public class ComboboxComponent extends TextboxComponent {

	public ComboboxComponent(Node component, Node parent) {
		super(component, parent);
	}

	public ValidationProperty[] getValidationProperties(ValidationInfo validationInfo) {
		return new ValidationProperty[] {
			new ValidationProperty(ValidationProperties.COMPONENT_NAME , validationInfo.componentName),
			new ValidationProperty(ValidationProperties.ID, validationInfo.id),
			new ValidationProperty(ValidationProperties.BUSINESS_NAME, validationInfo.businessName),
			new ValidationProperty(ValidationProperties.TYPE, validationInfo.type),
			new ValidationProperty(ValidationProperties.REQUIRED, validationInfo.required),
			new ValidationProperty(ValidationProperties.REQUIRED_GROUP, validationInfo.requiredGroup)
		};
	}

	public String[] getValidationTypes() {
		return new String[] {
			ValidationType.NONE,
			ValidationType.CUSTOM
		};
	}

	protected void paintFigure(Graphics graphics) {
		super.paintFigure(graphics);

		int x = bounds.x+bounds.width-20;
		int y = bounds.y;

		graphics.drawLine(x, y, x, y+bounds.height);

		PointList pointList = new PointList(3);
		pointList.addPoint(x+5, y+5);
		pointList.addPoint(x+15, y+5);
		pointList.addPoint(x+10, y+bounds.height-5);

		graphics.drawPolygon(pointList);
	}

}
